package com.lagou.rpc.consumer.controller;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.consumer.anno.RpcReference;
import com.lagou.rpc.consumer.proxy.RpcClientProxy;
import com.lagou.rpc.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: liufh
 * @create: 2021-11-10 11:23
 */
@RestController
public class UserController {

//    @Autowired
//    private RpcClientProxy rpcClientProxy;

    @RpcReference
    private IUserService userService;

    @RequestMapping("/query")
    public String query(Integer userId) {
//        IUserService userService = (IUserService) rpcClientProxy.createProxy(IUserService.class);
        User user = userService.getById(userId);
        System.out.println(user);
        return user.toString();
    }

}
